package com.wsd.smartcarwasher.dao;

import com.wsd.smartcarwasher.domain.CouponEntity;
import com.wsd.smartcarwasher.domain.UserCoupon;
import org.apache.ibatis.annotations.Param;
import org.springframework.dao.DataAccessException;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

public interface UserCouponDao {

    int addUserCoupon(UserCoupon userCoupon) throws DataAccessException;

    List<UserCoupon> getAllUnusedUserCoupons(String userId) throws DataAccessException;

    List<String> getAllUserCouponIds() throws DataAccessException;

    UserCoupon selectUserCoupon(String userCouponId) throws DataAccessException;

    int useUserCoupon(@Param("usedTime") Date usedTime, @Param("userCouponId") String userCouponId) throws DataAccessException;

    int rollBackUserCoupon(@Param("userCouponId") String userCouponId) throws DataAccessException;

    List<UserCoupon> getAllByCouponIdAndUserid(@Param("couponId")Integer couponId, @Param("userId")String userId);

    List<UserCoupon> getAllUserCoupons(String userId) throws DataAccessException;
    //优惠卷批量生成
    int addUserCouponByList(@Param("userCoupons") List<UserCoupon> userCoupons) throws DataAccessException;
    //根据卷码查询
    UserCoupon getCouponsByCode(String couponCode) throws DataAccessException;
    //绑定用户
    int bindUserCouponByCode(UserCoupon userCoupon) throws DataAccessException;

    UserCoupon getValidUserCouponByCouponId(int couponId) throws DataAccessException;

    UserCoupon getUserCouponById(String userCouponId);

    List<UserCoupon> getAllCouponListById(int couponId);

    int activationUserCoupon(@Param("userId") String userId,@Param("couponId") int couponId);

    /**
     * 检查用户有没有此类优惠卷
     * @param couponId
     * @param userId
     * @return
     */
    UserCoupon getUserCouponByIdAndUserId(@Param("couponId")int couponId,@Param("userId") String userId);

    int deleteByUserCouponId(String userCouponId);

    List<CouponEntity> getAllUnusedUserDiscountCoupons(String userId, Integer type, String machineId, BigDecimal price);

}
